﻿using Microsoft.Extensions.DependencyInjection;
using Qianke.Core.Saas.HttpApi.Client.Common;
using Volo.Abp.Http.Client;
using Volo.Abp.Modularity;

namespace Qianke.Core.Saas.HttpApi.Client
{
    [DependsOn(
        typeof(AbpHttpClientModule)
        )]
    public class SaasHttpApiClientModule : AbpModule
    {
        public override void PreConfigureServices(ServiceConfigurationContext context)
        {
            PreConfigure<AbpHttpClientBuilderOptions>(options =>
            {
                options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) =>
                {
                    clientBuilder.AddHttpMessageHandler(services => services.GetRequiredService<ISaasResultHttpMessageHandler>() as DelegatingHandler);
                });
            });
        }

    }
}
